%h4.page-title
  = link_to @project.name, @project
  @
  = @commit.short_sha
  
%p
  = link_to project_ref_commit_path(@project, @commit.ref, @commit.sha) do
    &larr; Back to project commit
%hr
#up-build-trace
- if @commit.matrix?
  %ul.nav.nav-tabs.append-bottom-10
    - @commit.builds_without_retry_sorted.each do |build|
      %li{class: ('active' if build == @build) }
        = link_to build_url(build) do
          %i{class: build_icon_css_class(build)}
          %span
            Build ##{build.id}
            - if build.name
              &middot;
              = build.name

    - unless @commit.builds_without_retry.include?(@build)
      %li.active
        %a
          Build ##{@build.id}
          &middot;
          %i.icon-warning-sign
          This build was retried.

.row
  .col-md-9
    .build-head.alert{class: build_status_alert_class(@build)}
      %h4
        - if @build.commit.tag?
          Build for tag
          %code #{@build.ref}
        - else
          Build for commit
          %code #{@build.short_sha}
          from

          = link_to project_path(@build.project, ref: @build.ref) do
            %span.label.label-primary= "#{@build.ref}"

        - if @build.duration
          .pull-right
            %span
              %i.icon-time
              #{duration_in_words(@build.finished_at, @build.started_at)}

      .clearfix
        = @build.status
        .pull-right
          = @build.updated_at.stamp('19:00 Aug 27')



    .clearfix
      - if @build.active?
        .autoscroll-container
          %button.btn.btn-success.btn-sm#autoscroll-button{:type => "button", :data => {:state => 'disabled'}} enable autoscroll
        .clearfix
    .scroll-controls
      = link_to '#up-build-trace', class: 'btn' do
        %i.icon-angle-up
      = link_to '#down-build-trace', class: 'btn' do
        %i.icon-angle-down

    %pre.trace#build-trace
      %code.bash
        = preserve do
          = raw @build.trace_html
    %div#down-build-trace

  .col-md-3
    - if @build.coverage
      .build-widget
        %h4.title
          Test coverage
        %h1 #{@build.coverage}%


    .build-widget
      %h4.title
        Build
        - if current_user && current_user.has_developer_access?(@project.gitlab_id)
          .pull-right
            - if @build.active?
              = link_to "Cancel", cancel_project_build_path(@project, @build), class: 'btn btn-sm btn-danger'
            - elsif @build.commands.present?
              = link_to "Retry", retry_project_build_path(@project, @build), class: 'btn btn-sm btn-primary', method: :post

      - if @build.duration
        %p
          %span.attr-name Duration:
          #{duration_in_words(@build.finished_at, @build.started_at)}
      %p
        %span.attr-name Created:
        #{time_ago_in_words(@build.created_at)} ago
      - if @build.finished_at
        %p
          %span.attr-name Finished:
          #{time_ago_in_words(@build.finished_at)} ago
      %p
        %span.attr-name Runner:
        - if @build.runner && current_user && current_user.is_admin
          \#{link_to "##{@build.runner.id}", admin_runner_path(@build.runner.id)}
        - elsif @build.runner
          \##{@build.runner.id}

    - if @build.trigger_request
      .build-widget
        %h4.title
          Trigger

        %p
          %span.attr-name Token:
          #{@build.trigger_request.trigger.short_token}

        - if @build.trigger_request.variables
          %p
            %span.attr-name Variables:

          %code
            - @build.trigger_request.variables.each do |key, value|
              #{key}=#{value}

    .build-widget
      %h4.title
        Commit
        .pull-right
          %small #{build_commit_link @build}

      - if @build.commit.compare?
        %p
          %span.attr-name Compare:
          #{build_compare_link @build}
      %p
        %span.attr-name Branch:
        #{build_ref_link @build}
      %p
        %span.attr-name Author:
        #{@build.commit.git_author_name}
      %p
        %span.attr-name Message:
        #{@build.commit.git_commit_message}

    - if @build.tags.any?
      .build-widget
        %h4.title
          Tags
        - @build.tag_list.each do |tag|
          %span.label.label-primary
            = tag

    - if @builds.present?
      .build-widget
        %h4.title #{pluralize(@builds.count, "other build")} for #{@build.short_sha}:
        %table.builds
          - @builds.each_with_index do |build, i|
            %tr.build.alert{class: build_status_alert_class(build)}
              %td
                = link_to build_url(build) do
                  %span ##{build.id}
              %td
                - if build.name
                  = build.name
              %td.status= build.status


        = paginate @builds


:javascript
  new Build("#{build_url(@build)}", "#{@build.status}")
